home *** CD-ROM | disk | FTP | other *** search
/ PC-Blue - MS DOS Public Domain Library / PC-Blue MS-DOS Public Domain Library - NYACC.iso / vol080 / defun.lsp < prev    next >
Encoding:
Text File  |  1987-01-14  |  1.0 KB  |  52 lines

  1.    ;  definition of add1
  2. (defun add1 (x) (+ x 1))
  3.  
  4.    ;  definition of sub1
  5. (defun sub1 (x) (- x 1))
  6.  
  7.    ;  definition of double
  8. (defun double (x) (* x x))
  9.  
  10.    ;  DEFINITION OF LESSP
  11. (defun lessp (x y)
  12.       (! (>= x y)))
  13.  
  14.    ;DEFINITION OF GRTP
  15. (defun grtp (x y)
  16.       (! (<= x y)))
  17.  
  18.    ; DEFINITION OF MINUS
  19. (defun minus (x)
  20.       (* x -1))
  21.  
  22.    ; DEFINITION OF ABS (ABSOLUTE VALUE)
  23. (defun abs (x)
  24.       (if (lessp x 0) (print (minus x)) (print x)))
  25.  
  26.    ;DEFINITION OF COMPARE
  27. (defun compare (x y)
  28.       (cond ((equal x y)     'numbers-are-the-same)
  29.             ((lessp x y) 'first-is-smaller)
  30.             ((grtp x y)  'first-is-bigger)))
  31.  
  32.    ; DEFINITION OF COMPUTE
  33. (defun compute (op x y)
  34.       (cond ((equal op 'add)      (+ x y))
  35.             ((equal op 'subtract) (- x y))
  36.             ((equal op 'multiply) (* x y))
  37.             ((equal op 'divide)   (/ x y))
  38.             (t '(I do not know how to do that))))
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50. (* x y))
  51.  
  52.